package com.example.schoolexam2.mapper;

import com.example.schoolexam2.entity.Exam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ExamMapper {
    //创建考试
    void createExam(Exam exam);
    //将试卷id和试题id保存到第三方关联表中
    void saveEIdAndQId(String examId,String questionId,String questionScore,String questionType);

    //通过班级信息查询到当前班级的考试id
    @Select("select examId from exam_class where classId=#{classId}")
    List<String> findExamByClassInfo(String classId);

    void saveExamAndClazz(String clazzId,String examId);

    //通过考试id查询第三方表得到当前考试的试题id
    List<Map<String,String>> findRadioIdByExamId(String examId);

    List<Map<String,String>> findCheckdIdByExamId(String examId);

    List<Map<String,String>> findFillIdByExamId(String examId);

    List<Map<String,String>> findJudgeIdByExamId(String examId);

    //通过试卷id查询试卷的实体
    @Select("select * from exam_page where examId=#{examId}")
    Exam findExamById(String examId);

    //将学生和试卷信息存入到表中
    void saveExamFromStudent(String studentId,String examId,String questionId,String studentChoose);

    //将学生当前试卷分数保存
    @Insert("insert into student_examScore values(null,#{studentId},#{examId},#{score})")
    void saveScore(String studentId,String examId,int score);
    @Select("select score from student_question_exam where studentId=#{studentId} and examId=#{examId}")
    int getStudentScore(String studentId,String examId);

    //通过学生id查询历史考试
    List<Map<String,String>> selectHostoryExam(String studentId);

    //老师查询试卷
    List<Exam> findExam(@Param("teacherDepartmentId")String departmentId, @Param("isPublic")String isPublic, @Param("teacherId")String teacherId, @Param("examName") String examName, @Param("start")int start, @Param("size")int end);
    //老师条件查询下，试卷的总数
    int findExamCount(@Param("teacherDepartmentId")String departmentId, @Param("isPublic")String isPublic,@Param("teacherId")String teacherId,@Param("examName") String examName);
}
